<section id="patreon">
  <h1>{{i18n "patreon.header.rules"}}</h1>
  <table>
    <thead>
      <tr>
        <th>{{i18n "patreon.group"}}</th>
        <th>{{i18n "patreon.rewards"}}</th>
        <th></th>
      </tr>
    </thead>

    <tbody>
      {{#each this.model as |rule|}}
        <tr class="">
          <td>{{rule.group}}</td>
          <td>{{rule.rewards}}</td>
          <td>
            <div class="pull-right">
              <DButton
                @action={{action "delete"}}
                @actionParam={{rule}}
                @icon="far-trash-can"
                @title="patreon.delete"
                class="delete btn-danger"
              />
            </div>
          </td>
        </tr>
      {{/each}}
    </tbody>

    <tfoot>
      <tr class="new-filter">
        <td><ComboBox
            @value={{this.editing.group_id}}
            @content={{this.groups}}
            @nameProperty="name"
            @valueProperty="id"
            @none="patreon.select_group"
          /></td>
        <td><ListSetting
            @value={{this.editing.reward_list}}
            @choices={{this.rewardsNames}}
            class="rewards"
          /></td>
        <td>
          <div class="pull-right">
            <DButton
              @action={{action "save"}}
              @icon="check"
              @title="patreon.save"
              class="save btn-primary"
            />
          </div>
        </td>
      </tr>
    </tfoot>
  </table>

  <p>{{i18n "patreon.help_text"}}</p>

  <DButton
    @action={{action "updateData"}}
    @icon="refresh"
    @disabled={{this.updatingData}}
    @title="patreon.update_data"
    @label="patreon.update_data"
  />

  {{#if this.last_sync_at}}
    <span class="last_synced">
      {{i18n "patreon.last_synced"}}:
      {{html-safe (format-date this.last_sync_at leaveAgo="true")}}
    </span>
  {{/if}}
</section>